package main

import (
	"io"
	"strings"
	"os"
)

const ORIG_CONTENT  = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
const ENCRYPTED_CONTENT = "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm"

type rot13Reader struct {
	r io.Reader
}

func (this rot13Reader) Read(data []byte) (int, error) {
	n, _err := this.r.Read(data)
	if _err == nil {
		a := data[:n]
		for i:=0;i<n;i++{
			index := strings.Index(ORIG_CONTENT,string(a[i]))
			if index >0{
				a[i] = ENCRYPTED_CONTENT[index]
			}
		}
	}
	return n, _err
}

func main() {
	s := strings.NewReader("Hello chou dudu")
	r := rot13Reader{s}
	io.Copy(os.Stdout, &r)
}
